<?php 

	function generate_name($student_id,$student_name)
	{
		if(empty($student_name)||$student_name==NULL||$student_name=="") 
		{
			$student_name = "未知";	
		}
		return '<a href="'.site_url('sale/clue_view/'.$student_id).'">'.$student_name.'</a>';
	}

	 function generate_no($student_id)
	{
		return 'D-'.sprintf('%06d',$student_id);
	}

	function generate_trade_wish($trade_wish)
	{
		if($trade_wish)
		{
			$wish = config_item('comm.trade_wish');
			return $wish[$trade_wish];
		}

		return NULL;
	}

	function generate_grade($grade)
	{
		if($grade)
		{
			$grades = config_item('comm.grade');

			return $grades[$grade];
		}
		return NULL;
	}

	function generate_status($status)
	{
		if($status)
		{
			$statuss = config_item('comm.clue_status');
			return $statuss[$status];
		}
		return NULL;
	}

	 function generate_actions($consultant,$student_id,$student_name)
	{
		$html = '<a href="'.site_url('/sale/clue_edit/'.$student_id).'" class="btn btn-xs btn-default">编辑</a> ';
		
		if(empty($consultant))
		{
			$html .= '<button class="btn btn-xs btn-warning clue_dist_btn" data-target="#dist_modal" data-toggle="modal" data-pk="'.$student_id.'">分配</button> ';
		}	
						
		$html .= '<button class="btn btn-xs btn-success clue_track_btn" data-target="#track_modal" data-toggle="modal" data-pk="'.$student_id.'">追踪</button> ';
		
		if(has_permission('sale/clues','clue_del'))
		{
			$html .= '<button data-pk="'.$student_id.'" class="btn btn-xs btn-danger clue_del_btn">删除</button>';
		}

		return $html;
	}